import { reactive, onMounted } from 'vue'

export default function () {
  // 鼠标位置
  const state = reactive({
    moveX: 0,
    moveY: 0
  })

  onMounted(() => {
    document.addEventListener(
      'mousemove',
      (e: MouseEvent) => {
        state.moveX = e.pageX
        state.moveY = e.pageY
      },
      false
    )
  })

  return {
    moveX: state.moveX,
    moveY: state.moveY
  }
}
